<template>
  <lab-bpmn :process-info="processInfo" />
</template>

<script>
import LabBpmn from "@/components/lab-bpmn/LabBpmn";
export default {
  name: "ProcessInfo",
  components: {LabBpmn},
  provide(){
    return {
      loadProcess: this.loadProcess,
      saveXml: this.saveXml
    }
  },
  inject: {
    appInfo: {
      from: 'appInfo',
      default: function () {
        return { appId: '0' }
      }
    }
  },
  props: {
    processInfo: {
      type: Object,
      default: function () {
        return { processDefId: this.$Util.uuid(4), processContent: ''}
      }
    }
  },
  methods: {
    loadProcess(callBack){
      callBack(this.processInfo.processContent || '', this.processInfo.processDefId, this.processInfo.processName)
    },
    saveXml(xml){
      this.processInfo.processContent = xml
      this.$post('/process/save?appId=' + this.appInfo.appId, this.processInfo)
          .then(res => {
            this.$resultMsg(this, res)
            if (res.code === 200) {
              this.$emit('save')
            }
          })
    }
  }
}
</script>

<style scoped>

</style>
